﻿using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using ZilLion.Core.ConfigManager.Manager;

namespace ZilLion.Core.DapperWrapper.SqlServer
{
    public class DefaultContext : IDbContext
    {
        public static string SystemDataConnectionString
            => ZilLionConfigurationManager.GetConfigInstance<DapperConfig>().DefaultConnection;

        public IDbConnection GetConnection()
        {
            if (SystemDataConnectionString.IsNullOrEmpty())
                return null;
            DbConnection connection = new SqlConnection(SystemDataConnectionString);
            return connection;
        }

        public string ContextName => "DefaultSource";
    }
}